package com.example.test0519.serviceImpl;

import com.example.test0519.bean.UserBean;
import com.example.test0519.bean.UserImgBean;
import com.example.test0519.mapper.UserMapper;
import com.example.test0519.service.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Sakura
 */
@Service
public class UserServiceImpl implements UserService {

    @Resource
    UserMapper userMapper;

    @Override
    public UserBean loginIn(String name, String password) {
        return userMapper.getInfo(name,password);
    }

    @Override
    public List<UserBean> getAllUser() {
        return userMapper.getAllUser();
    }

    @Override
    public int insertUser(UserBean userBean) {
        return userMapper.insertUser(userBean);
    }

    @Override
    public int deleteUser(String id) {
        return userMapper.deleteUser(id);
    }

    @Override
    public UserBean getUserById(String id) {
        return userMapper.getUserById(id);
    }

    @Override
    public int updateUser(UserBean userBean) {
        return userMapper.updateUser(userBean);
    }

    @Override
    public PageInfo<UserBean> selectUser4Page(Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        List<UserBean> users = userMapper.selectUser4Page();
        return new PageInfo<>(users);
    }

    @Override
    public int insertUserImg(UserImgBean userImgBean) {
        return userMapper.insertUserImg(userImgBean);
    }

    @Override
    public List<UserImgBean> getUserImgById(String user_id) {
        return userMapper.getUserImgById(user_id);
    }
}
